<?php
/*
Template Name: Categorii
*/
?>

<?php get_header(); ?>
	
		<div id="container">	
			<div id="content">
				<div id="category-content-page">
				<?php 
					$categories = get_categories(array('exclude' => '0', 'orderby' => 'name', 'hierarchical' => true));					
					foreach($categories as $category) {
						if ($category->parent == 0){
						echo '<div class="category-content">
								<div class="rootCategory"><a href="'.get_category_link($category->term_id).'" title="'.$category->cat_name.'">'. $category->cat_name.'</a></div>';
								 
							foreach($categories as $child){
								if ($child->parent == $category->cat_ID){
									$childLink = esc_url( get_permalink( get_page_by_title( trim($child->cat_name), 'OBJECT', 'post' ) ) );
									echo '<div><a href="'.$childLink.'" title="'.$child->cat_name.'">'.$child->cat_name.'</a></div>';
								}
							}
						echo '</div>';
						}
					}					
				?>
				</div>
			</div><!-- #content -->		
		</div><!-- #container -->
		
<?php get_sidebar(); ?>	
<?php get_footer(); ?>